﻿// owner 蒋家伟

#include "TaskId.h"
#include <xstddef>

using namespace jsdk;

const TaskId TaskId::s_InvalidTaskId = TaskId(0);

jsdk::TaskId::TaskId(size_t id):m_taskId(id)
{
}

bool jsdk::TaskId::isValid() const
{
    return m_taskId > 0;
}

size_t jsdk::TaskId::toValue() const
{
    return m_taskId;
}

bool jsdk::TaskId::operator==(const TaskId & taskId) const
{
    return m_taskId == taskId.m_taskId;
}

bool jsdk::TaskId::operator!=(const TaskId & taskId) const
{
    return !(*this == taskId);
}

TaskId & jsdk::TaskId::operator=(const TaskId & taskId)
{
    m_taskId = taskId.m_taskId;
    return *this;
}

bool jsdk::TaskId::operator<(const TaskId & taskId) const
{
    return m_taskId < taskId.m_taskId;
}

bool jsdk::TaskId::operator>(const TaskId & taskId) const
{
    return m_taskId > taskId.m_taskId;
}

size_t jsdk::HashTaskId::operator()(const TaskId & taskId) const
{
    return std::hash<size_t>().operator()(taskId.toValue());
}
